<?php
include_once 'include/functions.php';
$user = new User();

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $register = $user->register_user($_POST['name'], $_POST['username'], $_POST['password'], $_POST['email']);
  if ($register) {
    // Registration Success
    echo 'Registration  successful <a href="index.php">Click here</a> to login';
  }
  else {
    // Registration Failed
    echo 'Registration failed. Email or Username already exits please try again';
  }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

    <title>Hospital Management | Register</title>
    <style>
      body
      {
        font-family:Arial, Helvetica, sans-serif;
      }
    </style>
    <script language="javascript" type="text/javascript"> 
		
	
      function submitregistration() {
        var form = document.reg;
				
     
 
        if(form.name.value == "")
        {
          alert( "Enter name." );
          return false;
        }
        else if(form.username.value == "")
        {
          alert( "Enter username." );
          return false;
        }
        else if(form.password.value == "")
        {
          alert( "Enter password." );
          return false;
        }
        else if(form.email.value == "")
        {
          alert( "Enter email." );
          return false;
        }
 
 
      }
 
 
    </script> 
  </head>
  <body>
    <div id="container">

      <div id="main-body">
        <br/><br/>
        <form method="POST" action="register.php"  id="register_form" name="reg">
          <div class="head">
            <b> Register !</b><br/><br/>
          </div>
          <label>Full Name</label><br/>
          <input type="text" name="name"  required="true"/><br/><br/>
          <label>Username</label><br/>
          <input type="text" name="username"  required="true"/><br/><br/>
          <label>Password</label><br/>
          <input type="password" name="password" required="true"/><br/><br/>
          <label>Email</label><br/>
          <input type="text" name="email" id="email"  required="true"/><br/><br/>
          <input type="submit" name="register_btn" onclick="return( submitregistration());" value="Register"/><br/><br/>
          <label><a href="index.php">I already Registered. Login here</a></label>                    
        </form>


      </div>

    </div>
  </body>
</html>
